// Copyright 2022 The kubegems.io Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package environment

import (
	"github.com/gin-gonic/gin"
	"kubegems.io/kubegems/pkg/service/handlers/base"
)

type EnvironmentHandler struct {
	base.BaseHandler
}

func (h *EnvironmentHandler) RegistRouter(rg *gin.RouterGroup) {
	rg.GET("/environment", h.CheckIsSysADMIN, h.ListEnvironment)
	rg.GET("/environment/:environment_id", h.CheckByEnvironmentID, h.RetrieveEnvironment)
	rg.PUT("/environment/:environment_id", h.CheckByEnvironmentID, h.PutEnvironment)
	rg.DELETE("/environment/:environment_id", h.CheckByEnvironmentID, h.DeleteEnvironment)

	rg.GET("/environment/:environment_id/user", h.CheckByEnvironmentID, h.ListEnvironmentUser)
	rg.GET("/environment/:environment_id/user/:user_id", h.CheckByEnvironmentID, h.RetrieveEnvironmentUser)
	rg.POST("/environment/:environment_id/user", h.CheckByEnvironmentID, h.PostEnvironmentUser)
	rg.PUT("/environment/:environment_id/user/:user_id", h.CheckByEnvironmentID, h.PutEnvironmentUser)
	rg.DELETE("/environment/:environment_id/user/:user_id", h.CheckByEnvironmentID, h.DeleteEnvironmentUser)

	rg.POST("/environment/:environment_id/action/networkisolate", h.CheckByEnvironmentID, h.EnvironmentSwitch)
	rg.GET("/environment/:environment_id/resources", h.CheckByEnvironmentID, h.GetEnvironmentResource)

	rg.GET("/environment/:environment_id/observability", h.CheckByEnvironmentID, h.EnvironmentObservabilityDetails)
}
